
package nccloud.arap.manual.aggmanualcostvo.util.bp;

import java.util.HashMap;
import java.util.Map;

import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.ui.querytemplate.querytree.IQueryScheme;
import  nc.vo.arap.manualcost.AggManualCostVO;
import nc.vo.arap.manualcost.ManualCostVO;
import nccloud.commons.lang.ArrayUtils;
import nccloud.commons.lang.StringUtils;
import nccloud.arap.aggmanualcostvo.util.tool.PURPFileManageModeQuery;


public class ManualCostVOQueryBP {

    public AggManualCostVO[] queryByQueryScheme(IQueryScheme queryScheme) {
        PURPFileManageModeQuery<nc.vo.arap.manualcost.ManualCostVO> queryBillKeys = new PURPFileManageModeQuery<nc.vo.arap.manualcost.ManualCostVO>(nc.vo.arap.manualcost.ManualCostVO.class);
        String[] billKeys = queryBillKeys.queryBillKeysByQueryScheme(queryScheme, null);// 公共的
        billKeys = this.removeMulIds(billKeys);
        BillQuery<AggManualCostVO> query = new BillQuery<AggManualCostVO>(AggManualCostVO.class);
        AggManualCostVO[] bills = query.query(billKeys);
        return bills;
    }

    private String[] removeMulIds(String[] idarr) {
        if (ArrayUtils.isEmpty(idarr)) {
            return new String[0];
        }
        Map<String, String> idmap = new HashMap<String, String>();
        for (String id : idarr) {
            if (StringUtils.isNotBlank(id) && !idmap.containsKey(id)) {
                idmap.put(id, id);
            }
        }
        return idmap.keySet().toArray(new String[0]);
    }

}
